package main

import(
    "fmt"
)

var pipe chan int  // 在全局声明pipe变量，下面两个方法里都会用到

func add(a int, b int){
    sum := a + b
    pipe <- sum
}

func main(){
    pipe = make(chan int, 1)
    go add(1, 2)
    sum :=<- pipe
    fmt.Println("sum =", sum)
}